// pages/home/homeView.ts
Page({
    data: {
      isShowSearch:true,
      types:[
        { title:'猜你喜欢',list:[] },
        { title:'影院热映',list:[] },
        { title:'近期热门',list:[] }
      ],
      source:2
    },
    changeState(event:Event){
      this.setData({
        isShowSearch:event.target?.dataset?.state ?? true,
      })
    },
    initLoadFilm(){
      wx.request({
        url:"https://m.douban.com/rexxar/api/v2/movie/suggestion",
        method:"GET",
        data:{
          start:0,
          count:6,
          new_struct:1,
          with_review:1,
          for_mobile:1,
          ck:"sew4"
        },
        success:(result)=>{
          this.setData({
            "types[0].list":result?.data?.items
          })
        },
        fail:(error)=>{
          console.log(error);
        }
      })
      wx.request({
        url:"https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items",
        method:"GET",
        data:{
            start:0,
            count:6,
            new_struct:1,
            with_review:1,
            for_mobile:1,
            ck:"sew4"
        },
        success:(result)=>{
          this.setData({
            "types[1].list":result?.data?.items
          })
        },
        fail:(error)=>{
          console.log(error);
        }
      })
      wx.request({
        url:"https://m.douban.com/rexxar/api/v2/subject_collection/movie_latest/items",
        method:"GET",
        data:{
            start:0,
            count:6,
            new_struct:1,
            with_review:1,
            for_mobile:1,
            ck:"sew4"
        },
        success:(result)=>{
          this.setData({
            "types[2].list":result?.data?.items
          })
        },
        fail:(error)=>{
          console.log(error);
        }
      })
    },

    onLoad(){
      this.initLoadFilm();
    }
  })